home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / game / shoot / Heretic.lha / Heretic / c2p / c2p_highres.s < prev    next >
Text File  |  1999-02-19  |  7KB  |  344 lines

  1. ;c2p by Noe / Venus Art 5 pass cpu,for 040 cpu
  2.  
  3.         include "exec/types.i"
  4.         include "exec/funcdef.i"
  5.         include "exec/exec_lib.i"
  6.  
  7. ;3 functions must be provided:
  8. ; C2P_Init
  9. ; C2P_CleanUp
  10. ; C2P_Do
  11. ;
  12.  
  13. ; this in plugin module, cannot be started as any other program
  14.         moveq   #0,d0
  15.         rts
  16.  
  17. ; Do not change this:
  18.  
  19.         dc.b    "C2P",0                 ;module id, MUST BE 'C2P'!!!
  20.         dc.l    C2P_Init                ; pointer to init routine
  21.         dc.l    C2P_CleanUp             ;pointer to de-init routine
  22.         dc.l    C2P_Do                  ;pointer to main c2p function
  23.         dc.l    0
  24.  
  25.         cnop    0,4
  26. C2P_Init
  27. ; Here you can do all initializations needed by yours c2p
  28. ; In:
  29. ;  d0.l SCREENWIDTH
  30. ;  d1.l SCREENHEIGHT
  31. ; Out:
  32. ;  0  - something went wrong
  33. ;  1  - Init ok, C2P supports every resolution
  34. ;  2  - Init ok, C2P supports only 320x200 resolution.
  35.  
  36.         movem.l d2/d3/a6,-(sp)
  37.  
  38.         move.l  d0,d2
  39.         lsr.l   #3,d2           ;WIDTH_B = WIDTH>>3
  40.         move.w  d2,c2p_p6+2
  41.         move.w  d2,c2p_p12+2
  42.         move.w  d2,c2p_p15+2
  43.         move.w  d2,c2p_p20+2
  44.  
  45.         move.l  d2,d3
  46.         add.l   d2,d3           ;WIDTH_B*2
  47.         move.w  d3,c2p_p5+2
  48.         move.w  d3,c2p_p11+2
  49.         move.w  d3,c2p_p14+2
  50.         move.w  d3,c2p_p19+2
  51.  
  52.         add.l   d2,d3           ;WIDTH_B*3
  53.         move.w  d3,c2p_p4+2
  54.         move.w  d3,c2p_p9+2
  55.         move.w  d3,c2p_p13+2
  56.         move.w  d3,c2p_p18+2
  57.  
  58.         add.l   d2,d3           ;WIDTH_B*4
  59.         move.w  d3,c2p_p1+2
  60.  
  61.         add.l   d2,d3           ;WIDTH_B*5
  62.         add.l   d2,d3           ;WIDTH_B*6
  63.         add.l   d2,d3           ;WIDTH_B*7
  64.         move.w  d3,c2p_p7+2
  65.         move.w  d3,c2p_p16+2
  66.  
  67.         lsr.l   #2,d2           ;WIDTH/32
  68.         move.w  d2,c2p_p3+2
  69.         move.w  d2,c2p_p8+2
  70.         move.w  d2,c2p_p10+2
  71.         move.w  d2,c2p_p17+2
  72.  
  73.         mulu.l  d0,d1
  74.         move.l  d1,c2p_p2+4
  75.  
  76.         movea.l    4.w,a6
  77.     jsr    _LVOCacheClearU(a6)
  78.  
  79.         movem.l (sp)+,d2/d3/a6
  80.         moveq   #1,d0
  81.         rts
  82.  
  83.         cnop    0,4
  84. C2P_CleanUp
  85. ; Here you should clean all things you have made in C2P_Init 
  86. ; (like freeing memory, etc.)
  87. ; This module does nothing here... ;)
  88.         rts
  89.  
  90. ;some usefull macros
  91.  
  92. MOVE_HI_nBITS2    MACRO    ; data1, data2
  93.             ; data3, data4
  94.             ; mask, shift
  95.         and.l    \5,\1
  96.         and.l    \5,\2
  97.         and.l    \5,\3
  98.         and.l    \5,\4
  99.         lsr.l    #\6,\2
  100.         lsr.l    #\6,\4
  101.         or.l    \2,\1
  102.         or.l    \4,\3
  103.         ENDM
  104.  
  105. MERGE_nBITS2    MACRO    ; data1, data2, temp12,
  106.             ; data3, data4, temp34,
  107.             ; mask, shift
  108.         move.l    \2,\3            ; 2
  109.         move.l    \5,\6            ; 2
  110.         lsr.l    #\8,\3            ; 4
  111.         lsr.l    #\8,\6            ; 4
  112.         eor.l    \1,\3            ; 2
  113.         eor.l    \4,\6            ; 2
  114.         and.l    \7,\3            ; 2
  115.         and.l    \7,\6            ; 2
  116.         eor.l    \3,\1            ; 2
  117.         eor.l    \6,\4            ; 2
  118.     IFEQ    \8-1
  119.         add.l    \3,\3            ; 2
  120.         add.l    \6,\6            ; 2
  121.     ELSE
  122.         lsl.l    #\8,\3            ; 4
  123.         lsl.l    #\8,\6            ; 4
  124.     ENDC
  125.         eor.l    \3,\2            ; 2
  126.         eor.l    \6,\5            ; 2
  127.         ENDM                ; = 32/36
  128.  
  129. MERGE_WORD2    MACRO    ; data1, data2, temp12
  130.             ; data3, data4, temp34
  131.         move.l    \2,\3            ; 2
  132.         move.l    \5,\6            ; 2
  133.         move.w    \1,\2            ; 2
  134.         move.w    \4,\5            ; 2
  135.         swap    \2            ; 4
  136.         swap    \5            ; 4
  137.         move.w    \2,\1            ; 2
  138.         move.w    \5,\4            ; 2
  139.         move.w    \3,\2            ; 2
  140.         move.w    \6,\5            ; 2
  141.         ENDM                ; = 24
  142.  
  143. MOVE_LO_nBITS2    MACRO    ; data1, data2
  144.             ; data3, data4
  145.             ; mask, shift
  146.         and.l    \5,\1
  147.         and.l    \5,\2
  148.         and.l    \5,\3
  149.         and.l    \5,\4
  150.     IFEQ    \6-1
  151.         add.l    \2,\1
  152.         add.l    \4,\3
  153.     ELSE
  154.         lsl.l    #\6,\1
  155.         lsl.l    #\6,\3
  156.     ENDC
  157.         or.l    \2,\1
  158.         or.l    \4,\3
  159.         ENDM
  160.  
  161. ;hardcoded screen resolution.
  162. ;It is possible to patch this routine to use other resolution than 320x200
  163. ; but it requires selfmodyfing code.
  164.  
  165. WIDTH        EQU    320
  166. HEIGHT        EQU    200
  167. WIDTH_B        EQU    WIDTH>>3
  168.  
  169.         cnop    0,4
  170. C2P_Do
  171. ;Core c2p routine.
  172. ;
  173. ; In:
  174. ;  a0.l - pointer to chunky in fastmem. (SCREENWIDTH*SCREENHEIGHT)
  175. ;  a1.l - pointer to INTERLEAVED bitplanes
  176. ; Out:
  177. ;  None
  178.         movem.l    d2-d7/a2-a6,-(sp)
  179.  
  180.         move.l    a1,-(sp)
  181.         move.l    a0,-(sp)
  182.  
  183. c2p_p1        lea    (a1,(4*WIDTH_B).w),a1
  184. c2p_p2        lea    (a0,(WIDTH*HEIGHT).l),a2
  185.  
  186.         move.l    #$00ff00ff,a6
  187.  
  188. c2p_p3        move.w    #WIDTH/32,d7
  189.  
  190.         move.l    #$f0f0f0f0,d6
  191.  
  192.         movem.l    (a0)+,d0/d1/d2/d3
  193.  
  194.         MOVE_HI_nBITS2    d0,d1,d2,d3,d6,4
  195.  
  196.         movem.l    (a0)+,d1/d3/d4/d5
  197.  
  198.         MOVE_HI_nBITS2    d1,d3,d4,d5,d6,4
  199.  
  200.         move.l    a6,d6
  201.         MERGE_nBITS2    d0,d2,d3,d1,d4,d5,d6,8
  202.  
  203.         MERGE_WORD2    d0,d1,d3,d2,d4,d5
  204.  
  205.         move.l    #$33333333,d6
  206.         MERGE_nBITS2    d0,d1,d3,d2,d4,d5,d6,2
  207.  
  208.         move.l    #$55555555,d6
  209.         MERGE_nBITS2    d0,d2,d3,d1,d4,d5,d6,1
  210.  
  211. c2p_p4        move.l    d0,(a1,(3*WIDTH_B).w)
  212.         move.l    d2,a3
  213.         move.l    d1,a4
  214.         move.l    d4,a5
  215.  
  216. C2P_FI_320x200C_loop1
  217.         move.l    #$f0f0f0f0,d6
  218.  
  219.         movem.l    (a0)+,d0/d1/d2/d3
  220.  
  221.         MOVE_HI_nBITS2    d0,d1,d2,d3,d6,4
  222.  
  223.         movem.l    (a0)+,d1/d3/d4/d5
  224.  
  225. c2p_p5        move.l    a3,(a1,(2*WIDTH_B).w)
  226.  
  227.         MOVE_HI_nBITS2    d1,d3,d4,d5,d6,4
  228.  
  229.         move.l    a6,d6
  230.         MERGE_nBITS2    d0,d2,d3,d1,d4,d5,d6,8
  231.  
  232. c2p_p6        move.l    a4,(a1,(1*WIDTH_B).w)
  233.  
  234.         MERGE_WORD2    d0,d1,d3,d2,d4,d5
  235.  
  236.         move.l    #$33333333,d6
  237.         MERGE_nBITS2    d0,d1,d3,d2,d4,d5,d6,2
  238.  
  239.         move.l    a5,(a1)+
  240.  
  241.         subq.w    #1,d7
  242.         bne.b    C2P_FI_320x200C_1
  243. c2p_p7        lea    (a1,(7*WIDTH_B).w),a1
  244. c2p_p8        move.w    #WIDTH/32,d7
  245. C2P_FI_320x200C_1
  246.  
  247.         move.l    #$55555555,d6
  248.         MERGE_nBITS2    d0,d2,d3,d1,d4,d5,d6,1
  249.  
  250.         move.l    d2,a3
  251.         move.l    d1,a4
  252.         move.l    d4,a5
  253. c2p_p9        move.l    d0,(a1,(3*WIDTH_B).w)
  254.  
  255.         cmpa.l    a2,a0
  256.         bne.w    C2P_FI_320x200C_loop1
  257.  
  258.         move.l    (sp)+,a0
  259.  
  260. c2p_p10        move.w    #WIDTH/32,d7
  261.  
  262.         move.l    #$0f0f0f0f,d6
  263.  
  264.         movem.l    (a0)+,d0/d1/d2/d3
  265.  
  266.         MOVE_LO_nBITS2    d0,d1,d2,d3,d6,4
  267.  
  268.         movem.l    (a0)+,d1/d3/d4/d5
  269.  
  270. c2p_p11        move.l    a3,(a1,(2*WIDTH_B).w)
  271.  
  272.         MOVE_LO_nBITS2    d1,d3,d4,d5,d6,4
  273.  
  274.         move.l    a6,d6
  275.         MERGE_nBITS2    d0,d2,d3,d1,d4,d5,d6,8
  276.  
  277. c2p_p12        move.l    a4,(a1,(1*WIDTH_B).w)
  278.  
  279.         MERGE_WORD2    d0,d1,d3,d2,d4,d5
  280.  
  281.         move.l    #$33333333,d6
  282.         MERGE_nBITS2    d0,d1,d3,d2,d4,d5,d6,2
  283.  
  284.         move.l    a5,(a1)
  285.  
  286.         move.l    #$55555555,d6
  287.         MERGE_nBITS2    d0,d2,d3,d1,d4,d5,d6,1
  288.  
  289.         move.l    (sp)+,a1
  290.  
  291. c2p_p13        move.l    d0,(a1,(3*WIDTH_B).w)
  292.         move.l    d2,a3
  293.         move.l    d1,a4
  294.         move.l    d4,a5
  295.  
  296. C2P_FI_320x200C_loop2
  297.         move.l    #$0f0f0f0f,d6
  298.  
  299.         movem.l    (a0)+,d0/d1/d2/d3
  300.  
  301.         MOVE_LO_nBITS2    d0,d1,d2,d3,d6,4
  302.  
  303.         movem.l    (a0)+,d1/d3/d4/d5
  304.  
  305. c2p_p14        move.l    a3,(a1,(2*WIDTH_B).w)
  306.  
  307.         MOVE_LO_nBITS2    d1,d3,d4,d5,d6,4
  308.  
  309.         move.l    a6,d6
  310.         MERGE_nBITS2    d0,d2,d3,d1,d4,d5,d6,8
  311.  
  312. c2p_p15        move.l    a4,(a1,(1*WIDTH_B).w)
  313.  
  314.         MERGE_WORD2    d0,d1,d3,d2,d4,d5
  315.  
  316.         move.l    #$33333333,d6
  317.         MERGE_nBITS2    d0,d1,d3,d2,d4,d5,d6,2
  318.  
  319.         move.l    a5,(a1)+
  320.  
  321.         subq.w    #1,d7
  322.         bne.b    C2P_FI_320x200C_2
  323. c2p_p16        lea    (a1,(7*WIDTH_B).w),a1
  324. c2p_p17        move.w    #WIDTH/32,d7
  325. C2P_FI_320x200C_2
  326.  
  327.         move.l    #$55555555,d6
  328.         MERGE_nBITS2    d0,d2,d3,d1,d4,d5,d6,1
  329.  
  330.         move.l    d2,a3
  331.         move.l    d1,a4
  332.         move.l    d4,a5
  333. c2p_p18        move.l    d0,(a1,(3*WIDTH_B).w)
  334.  
  335.         cmpa.l    a2,a0
  336.         bne.w    C2P_FI_320x200C_loop2
  337.  
  338. c2p_p19        move.l    a3,(a1,(2*WIDTH_B).w)
  339. c2p_p20        move.l    a4,(a1,(1*WIDTH_B).w)
  340.         move.l    a5,(a1)
  341.  
  342.         movem.l    (sp)+,d2-d7/a2-a6
  343.                 rts
  344.